package vn.com.epi.re.data;

public class Visit {
    private long timestamp;
    private String userId;
    private int preference;
    private int articleId;
    private int categoryId;
    
    public Visit() {        
    }
    
    public Visit(String line) {
        String[] chunks = line.split(",");
        if (chunks.length == 5) {
            try {
                timestamp = Long.parseLong(chunks[0]);
            } catch (NumberFormatException e) {
                timestamp = 0; // default
            }
            userId = chunks[1];
            try {
                preference = Integer.parseInt(chunks[2].substring(3, chunks[2].length()));
            } catch (NumberFormatException e) {
                preference = 0;
            }
            try {
                articleId = Integer.parseInt(chunks[3]);
            } catch (NumberFormatException e) {
                articleId = 0;
            }
            try {
                categoryId = Integer.parseInt(chunks[4]);
            } catch (NumberFormatException e) {
                categoryId = 0;
            }
        }
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getPreference() {
        return preference;
    }

    public void setPreference(int preference) {
        this.preference = preference;
    }

    public int getArticleId() {
        return articleId;
    }

    public void setArticleId(int articleId) {
        this.articleId = articleId;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

}
